<layout name='../Layout/frame_main' />

<body>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<div class="page-header">
				<h2>
					权限列表  
					 <small>共{$count}条数据</small>
					 <br/><a href="#myAdd" class="btn btn-small btn-primary" data-toggle="modal">新建权限</a>
				</h2>
			</div>
			<?php 
			if(count($list)==0)
			{
				echo '<h4>暂时没有数据</h4>';
			}
			else
			{
			?>
			<table class="table table-bordered table-hover table-condensed">
				<thead>
					<tr>
						<th>
							编号
						</th>
						<th>
							名称
						</th><th>
							有效性
						</th>
						
						<th>
							简述
						</th>
						<th>
							删除
						</th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr >
						<td>
							{$vo.rol_id}
						</td>
						<td>
							{$vo.rol_name}
						</td>
						<td>
							<label class="checkbox">
								<?php
								if($vo["rol_valid"]==1)
									echo "<input type='checkbox' checked /><span>有效</span>";
								else 
									echo "<input type='checkbox' /><span>无效</span>";
								 ?>
						</label>							
						</td>
						<td>
							{$vo.rol_desc}
						</td>
						
						<td>
						<a data-toggle="modal" class="btn btn-primary" role="button" href="#myModal{$i}">权限详情</a>
						</td>
<form id="form{$i}" action="__URL__/adr/" method='post'>
  							  <div id="myModal{$i}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								    <div class="modal-header">
								      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								      <h3 id="myModalLabel">添加权限</h3>
								    </div>
								    <div class="modal-body">
									    <div class="container-fluid">
											<div class="row-fluid">
												<div class="span12">
													<div class="row-fluid">
	<div class="span8">
		<span class='cn_name'></span><span class='cn_val'>

		</span><br/>	
		<input type="hidden" name="rol_id" value="{$vo.rol_id}" />
		<input type="hidden" name="rol_valid" value="{$vo.rol_valid}" />
		<span class='cn_name'>名称&nbsp; </span><span class='cn_val'><input type="text" name="rol_name"  value='{$vo.rol_name}' /></span><br/>
		<span class='cn_name'>描述&nbsp; </span><span class='cn_val'><input type="text" name="rol_desc"  value='{$vo.rol_desc}' /></span><br/>
	</div>
													</div>
												</div>
											</div>
										</div>
								    </div>
								    <div class="modal-footer">
								      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn">关闭</button>
								      <button class="btn btn-primary" type="submit">确认</button>
								    </div>
							  </div>
							</form>
					</tr>
				</volist>
				</tbody>
			</table>
			<div class="pagination pagination-centered">
				<ul>
					<li>{$page}</li>
				</ul>
			</div>
			<?php } ?>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span12">
		</div>
	</div>
</div>

<form id="formadd" action="__URL__/adr" method='post'>
							  <div id="myAdd" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								    <div class="modal-header">
								      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								      <h3 id="myModalLabel">添加权限</h3>
								    </div>
								    <div class="modal-body">
									    <div class="container-fluid">
											<div class="row-fluid">
												<div class="span12">
													<div class="row-fluid">
	<div class="span8">
		<span class='cn_name'></span><span class='cn_val'>

		</span><br/>	
		<input type="hidden" name="rol_valid" value="" />
		<span class='cn_name'>名称&nbsp; </span><span class='cn_val'><input type="text" name="rol_name"  value='' /></span><br/>
		<span class='cn_name'>描述&nbsp; </span><span class='cn_val'><input type="text" name="rol_desc"  value='' /></span><br/>
	</div>
													</div>
												</div>
											</div>
										</div>
								    </div>
								    <div class="modal-footer">
								      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn">关闭</button>
								      <button class="btn btn-primary" type="submit">确认</button>
								    </div>
							  </div>
							</form>

</body>

<script type="text/javascript">
$(function(){
	$('input:checkbox').click(function(){
		var v=$.trim($(this).parent().parent().parent().children(':first').text());
		var tc=this;
		$.post(
			"__URL__/check/",
			'rvalue='+v+'&data='+(this.checked?1:0),
			function(data){
				if(data=='OK')
				{
					$(tc).next().text(!tc.checked?'无效':'有效');
					alert('处理成功！');
				}
				else
				{
					alert('处理失败！');
					tc.checked=!tc.checked;
				}
			});
	});
})
	
</script>